#include "statistic.h"
Statistic::Statistic(string sym) {
    this->symbol = sym;
    this->last_time_stamp = -1;
    this->max_price = -1;
    this->total_trade = 0;
    this->volume = 0;
    this->weighted_average_price = 0;
    this->max_time_stamp = 0;
}
void Statistic::feed_data(int64_t time_stamp, int64_t quality, int64_t price) {
    this->volume += quality;
    this->total_trade += quality * price;
    this->max_price = max(this->max_price, price);
    //cout<<time_stamp - this->last_time_stamp<<endl;
    if (this->last_time_stamp != -1)
        this->max_time_stamp = max(this->max_time_stamp, time_stamp - this->last_time_stamp);
    this->last_time_stamp = time_stamp;
}

void Statistic::finish() {
    this->weighted_average_price = this->total_trade / this->volume;
}